This must be one of those things that people mess up on when they're tired o_o. Please help me find what's wrong with the following code:
Code:
#include <stdio.h>
double pow(double base, int exp);
int factorial(int num);
main()
{
int n = 1;
double term = 1, approximation = 1, exp;
printf("Approximate e^x. x: ");
scanf("%f", &exp);
printf("EXP is %f\n", exp);
getchar();
}
double pow(double base, int exp)
{
int i;
double product = 1;
if(base == 0)
return 0;
for(i = 0; i < exp; i++)
product *= base;
return product;
}
int factorial(int num)
{
int i, product = 1;
if(num == 0)
return 0;
for(i = 2; i <= num; i++)
product *= i;
return product;
}
Thanks.